<!DOCTYPE html>

<html lang="en">
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>cup.shell.expect &#8212; cup 3.2.33 documentation</title>
    <link rel="stylesheet" type="text/css" href="../../../_static/pygments.css" />
    <link rel="stylesheet" type="text/css" href="../../../_static/alabaster.css" />
    <script data-url_root="../../../" id="documentation_options" src="../../../_static/documentation_options.js"></script>
    <script src="../../../_static/doctools.js"></script>
    <script src="../../../_static/sphinx_highlight.js"></script>
    <link rel="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
   
  <link rel="stylesheet" href="../../../_static/custom.css" type="text/css" />
  
  
  <meta name="viewport" content="width=device-width, initial-scale=0.9, maximum-scale=0.9" />

  </head><body>
  

    <div class="document">
      <div class="documentwrapper">
        <div class="bodywrapper">
          

          <div class="body" role="main">
            
  <h1>Source code for cup.shell.expect</h1><div class="highlight"><pre>
<span></span><span class="ch">#!/usr/bin/env python</span>
<span class="c1"># -*- coding: utf-8 -*</span>
<span class="c1"># Copyright: [CUP] - See LICENSE for details.</span>
<span class="c1"># Authors: Weiyan Lin</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">:description:</span>
<span class="sd">    made a wraper out of paramiko.**</span>
<span class="sd">    The original copyright belongs to the author of paramiko module.</span>
<span class="sd">    See it at http://docs.paramiko.org/en/stable/</span>
<span class="sd">&quot;&quot;&quot;</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">traceback</span>
<span class="kn">import</span> <span class="nn">stat</span>

<span class="kn">import</span> <span class="nn">cup</span>
<span class="kn">import</span> <span class="nn">paramiko</span>
<span class="kn">from</span> <span class="nn">paramiko</span> <span class="kn">import</span> <span class="n">ssh_exception</span>


<span class="n">__all__</span> <span class="o">=</span> <span class="p">[</span>
    <span class="s1">&#39;checkssh&#39;</span><span class="p">,</span> <span class="s1">&#39;go_ex&#39;</span><span class="p">,</span> <span class="s1">&#39;lscp&#39;</span><span class="p">,</span> <span class="s1">&#39;dscp&#39;</span><span class="p">,</span> <span class="s1">&#39;go_with_scp&#39;</span>
<span class="p">]</span>


<span class="k">def</span> <span class="nf">_connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">22</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    get connect</span>
<span class="sd">    :param hostname:</span>
<span class="sd">    :param username:</span>
<span class="sd">    :param passwd:</span>
<span class="sd">    :param timeout:</span>
<span class="sd">    :param port:</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">client</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">paramiko</span><span class="o">.</span><span class="n">SSHClient</span><span class="p">()</span>
        <span class="n">client</span><span class="o">.</span><span class="n">set_missing_host_key_policy</span><span class="p">(</span><span class="n">paramiko</span><span class="o">.</span><span class="n">AutoAddPolicy</span><span class="p">())</span>
        <span class="n">client</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">port</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="n">timeout</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">ssh_exception</span><span class="o">.</span><span class="n">NoValidConnectionsError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;username not exists&quot;</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">ssh_exception</span><span class="o">.</span><span class="n">AuthenticationException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;passwd not correct&quot;</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;*** Caught exception: </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
        <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>
    <span class="k">return</span> <span class="n">client</span>


<span class="k">def</span> <span class="nf">_sftp_connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="n">port</span><span class="o">=</span><span class="mi">22</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    get sftp connect</span>
<span class="sd">    :param hostname:</span>
<span class="sd">    :param username:</span>
<span class="sd">    :param passwd:</span>
<span class="sd">    :param timeout:</span>
<span class="sd">    :param port:</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">client</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="n">sftp</span> <span class="o">=</span> <span class="kc">None</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">client</span> <span class="o">=</span> <span class="n">paramiko</span><span class="o">.</span><span class="n">SSHClient</span><span class="p">()</span>
        <span class="n">client</span><span class="o">.</span><span class="n">set_missing_host_key_policy</span><span class="p">(</span><span class="n">paramiko</span><span class="o">.</span><span class="n">AutoAddPolicy</span><span class="p">())</span>
        <span class="n">client</span><span class="o">.</span><span class="n">connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">port</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="n">timeout</span><span class="p">)</span>
        <span class="n">sftp</span> <span class="o">=</span> <span class="n">paramiko</span><span class="o">.</span><span class="n">SFTPClient</span><span class="o">.</span><span class="n">from_transport</span><span class="p">(</span><span class="n">client</span><span class="o">.</span><span class="n">get_transport</span><span class="p">())</span>
    <span class="k">except</span> <span class="n">ssh_exception</span><span class="o">.</span><span class="n">NoValidConnectionsError</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;username not exists&quot;</span><span class="p">)</span>
    <span class="k">except</span> <span class="n">ssh_exception</span><span class="o">.</span><span class="n">AuthenticationException</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;passwd not correct&quot;</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;*** Caught exception: </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
        <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>
    <span class="k">return</span> <span class="n">client</span><span class="p">,</span> <span class="n">sftp</span>


<span class="k">def</span> <span class="nf">_close</span><span class="p">(</span><span class="n">client</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    disconnect client</span>
<span class="sd">    :param client:</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">client</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;*** Caught exception: </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
        <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>


<span class="k">def</span> <span class="nf">_is_exists</span><span class="p">(</span><span class="n">path</span><span class="p">,</span> <span class="n">function</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    check path exists</span>
<span class="sd">    :param path:</span>
<span class="sd">    :param function:</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">path</span> <span class="o">=</span> <span class="n">path</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\\</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;/&#39;</span><span class="p">)</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">function</span><span class="p">(</span><span class="n">path</span><span class="p">)</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="k">return</span> <span class="kc">False</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="k">return</span> <span class="kc">True</span>


<span class="k">def</span> <span class="nf">_check_local</span><span class="p">(</span><span class="n">local</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    check dir exists, if not exists then make dir</span>
<span class="sd">    :param local:</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">local</span><span class="p">):</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">os</span><span class="o">.</span><span class="n">mkdir</span><span class="p">(</span><span class="n">local</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">except</span> <span class="ne">IOError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">err</span><span class="p">)</span>
            <span class="k">return</span> <span class="kc">False</span>


<span class="k">def</span> <span class="nf">_put</span><span class="p">(</span><span class="n">sftp</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    put file/dir</span>
<span class="sd">    :param sftp:</span>
<span class="sd">    :param src:</span>
<span class="sd">    :param dst:</span>
<span class="sd">    :return: msg</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">normpath</span><span class="p">(</span><span class="n">src</span><span class="p">))</span>
    <span class="n">dst</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dst</span><span class="p">,</span> <span class="n">name</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\\</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;/&#39;</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isdir</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
        <span class="n">_is_exists</span><span class="p">(</span><span class="n">dst</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="n">sftp</span><span class="o">.</span><span class="n">mkdir</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
            <span class="n">src_file</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\\</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;/&#39;</span><span class="p">)</span>
            <span class="n">msg</span> <span class="o">=</span> <span class="n">_put</span><span class="p">(</span><span class="n">sftp</span><span class="o">=</span><span class="n">sftp</span><span class="p">,</span> <span class="n">src</span><span class="o">=</span><span class="n">src_file</span><span class="p">,</span> <span class="n">dst</span><span class="o">=</span><span class="n">dst</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="n">msg</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">isfile</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">sftp</span><span class="o">.</span><span class="n">put</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
            <span class="n">msg</span> <span class="o">+=</span> <span class="s1">&#39;[put] &#39;</span> <span class="o">+</span> <span class="n">src</span> <span class="o">+</span> <span class="s1">&#39;==&gt;&#39;</span> <span class="o">+</span> <span class="n">dst</span> <span class="o">+</span> <span class="s1">&#39; failed</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">msg</span> <span class="o">+=</span> <span class="s1">&#39;[put] &#39;</span> <span class="o">+</span> <span class="n">src</span> <span class="o">+</span> <span class="s1">&#39;==&gt;&#39;</span> <span class="o">+</span> <span class="n">dst</span> <span class="o">+</span> <span class="s1">&#39; successed</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="k">return</span> <span class="n">msg</span>


<span class="k">def</span> <span class="nf">_get</span><span class="p">(</span><span class="n">sftp</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    get file/dir</span>
<span class="sd">    :param sftp:</span>
<span class="sd">    :param src:</span>
<span class="sd">    :param dst:</span>
<span class="sd">    :return: msg</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">result</span> <span class="o">=</span> <span class="n">sftp</span><span class="o">.</span><span class="n">stat</span><span class="p">(</span><span class="n">src</span><span class="p">)</span>
    <span class="k">if</span> <span class="n">stat</span><span class="o">.</span><span class="n">S_ISDIR</span><span class="p">(</span><span class="n">result</span><span class="o">.</span><span class="n">st_mode</span><span class="p">):</span>
        <span class="n">dirname</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">normpath</span><span class="p">(</span><span class="n">src</span><span class="p">))</span>
        <span class="n">dst</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dst</span><span class="p">,</span> <span class="n">dirname</span><span class="p">)</span>
        <span class="n">_check_local</span><span class="p">(</span><span class="n">dst</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">sftp</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">src</span><span class="p">):</span>
            <span class="n">sub_remote</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">file</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;</span><span class="se">\\</span><span class="s1">&#39;</span><span class="p">,</span> <span class="s1">&#39;/&#39;</span><span class="p">)</span>
            <span class="n">msg</span> <span class="o">=</span> <span class="n">_get</span><span class="p">(</span><span class="n">sftp</span><span class="p">,</span> <span class="n">sub_remote</span><span class="p">,</span> <span class="n">dst</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="n">msg</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">dst</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">dst</span><span class="p">,</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">basename</span><span class="p">(</span><span class="n">src</span><span class="p">))</span>
        <span class="k">try</span><span class="p">:</span>
            <span class="n">sftp</span><span class="o">.</span><span class="n">get</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">)</span>
        <span class="k">except</span> <span class="ne">IOError</span> <span class="k">as</span> <span class="n">err</span><span class="p">:</span>
            <span class="n">msg</span> <span class="o">+=</span> <span class="s1">&#39;[get] &#39;</span> <span class="o">+</span> <span class="n">src</span> <span class="o">+</span> <span class="s1">&#39;==&gt;&#39;</span> <span class="o">+</span> <span class="n">dst</span> <span class="o">+</span> <span class="s1">&#39; failed</span><span class="se">\n</span><span class="s1">&#39;</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">msg</span> <span class="o">+=</span> <span class="s1">&#39;[get] &#39;</span> <span class="o">+</span> <span class="n">src</span> <span class="o">+</span> <span class="s1">&#39;==&gt;&#39;</span> <span class="o">+</span> <span class="n">dst</span> <span class="o">+</span> <span class="s1">&#39; successed</span><span class="se">\n</span><span class="s1">&#39;</span>
    <span class="k">return</span> <span class="n">msg</span>


<span class="k">def</span> <span class="nf">to_str</span><span class="p">(</span><span class="n">bytes_or_str</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    把byte类型转换为str</span>
<span class="sd">    :param bytes_or_str:</span>
<span class="sd">    :return:</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">if</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">bytes_or_str</span><span class="p">,</span> <span class="nb">bytes</span><span class="p">):</span>
        <span class="n">value</span> <span class="o">=</span> <span class="n">bytes_or_str</span><span class="o">.</span><span class="n">decode</span><span class="p">(</span><span class="s1">&#39;utf-8&#39;</span><span class="p">)</span>
    <span class="k">else</span><span class="p">:</span>
        <span class="n">value</span> <span class="o">=</span> <span class="n">bytes_or_str</span>
    <span class="k">return</span> <span class="n">value</span>


<div class="viewcode-block" id="checkssh"><a class="viewcode-back" href="../../../cup.shell.html#cup.shell.expect.checkssh">[docs]</a><span class="k">def</span> <span class="nf">checkssh</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    check if we can ssh to hostname.</span>
<span class="sd">    :return:a dict with keys (&#39;exitstatus&#39;, &#39;result&#39;) exitstatus 0 success -1 others</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="k">return</span> <span class="n">go_ex</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="s1">&#39;echo &quot;testSSH&quot;&#39;</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">8</span><span class="p">)</span></div>


<div class="viewcode-block" id="go_ex"><a class="viewcode-back" href="../../../cup.shell.html#cup.shell.expect.go_ex">[docs]</a><span class="k">def</span> <span class="nf">go_ex</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">command</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">600</span><span class="p">,</span>
    <span class="n">b_print_stdout</span><span class="o">=</span><span class="kc">True</span>
<span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    execute command at remote.</span>
<span class="sd">    :return:a dict with keys (&#39;exitstatus&#39;, &#39;result&#39;) exitstatus 0 success -1 others</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;result&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span><span class="p">,</span>
        <span class="s1">&#39;result_stderr&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span>
    <span class="p">}</span>
    <span class="n">client</span> <span class="o">=</span> <span class="n">_connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="mi">22</span><span class="p">)</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">stdin</span><span class="p">,</span> <span class="n">stdout</span><span class="p">,</span> <span class="n">stderr</span> <span class="o">=</span> <span class="n">client</span><span class="o">.</span><span class="n">exec_command</span><span class="p">(</span><span class="n">command</span><span class="p">)</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">stdout</span><span class="o">.</span><span class="n">channel</span><span class="o">.</span><span class="n">recv_exit_status</span><span class="p">()</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">to_str</span><span class="p">(</span><span class="n">stdout</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result_stderr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">to_str</span><span class="p">(</span><span class="n">stderr</span><span class="o">.</span><span class="n">read</span><span class="p">())</span>
        <span class="k">if</span> <span class="n">b_print_stdout</span><span class="p">:</span>
            <span class="nb">print</span><span class="p">(</span><span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">])</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;*** Caught exception: </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
        <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result_stderr&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">e</span>
    <span class="k">finally</span><span class="p">:</span>
        <span class="n">_close</span><span class="p">(</span><span class="n">client</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">ret</span></div>


<div class="viewcode-block" id="lscp"><a class="viewcode-back" href="../../../cup.shell.html#cup.shell.expect.lscp">[docs]</a><span class="k">def</span> <span class="nf">lscp</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">dst</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">800</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    copy [localhost]:src to [hostname]:[dst]</span>

<span class="sd">    :return:a dict with keys (&#39;exitstatus&#39;, &#39;result&#39;) exitstatus 0 success -1 others</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;result&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span>
    <span class="p">}</span>
    <span class="n">client</span><span class="p">,</span> <span class="n">sftp</span> <span class="o">=</span> <span class="n">_sftp_connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="mi">22</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">client</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">sftp</span><span class="p">:</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;connect remote host error&#39;</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">_is_exists</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">):</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&#39;&quot;</span> <span class="o">+</span> <span class="n">src</span> <span class="o">+</span> <span class="s2">&quot;&#39;: No such file or directory in local&quot;</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">_is_exists</span><span class="p">(</span><span class="n">dst</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="n">sftp</span><span class="o">.</span><span class="n">stat</span><span class="p">):</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&#39;&quot;</span> <span class="o">+</span> <span class="n">dst</span> <span class="o">+</span> <span class="s2">&quot;&#39;: No such directory at remote&quot;</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">msg</span> <span class="o">=</span> <span class="n">_put</span><span class="p">(</span><span class="n">sftp</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">)</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">msg</span>
        <span class="k">if</span> <span class="n">msg</span><span class="o">.</span><span class="fm">__contains__</span><span class="p">(</span><span class="s1">&#39;failed&#39;</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">ret</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;*** Caught exception: </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
        <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
    <span class="k">finally</span><span class="p">:</span>
        <span class="n">_close</span><span class="p">(</span><span class="n">client</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">ret</span></div>


<div class="viewcode-block" id="dscp"><a class="viewcode-back" href="../../../cup.shell.html#cup.shell.expect.dscp">[docs]</a><span class="k">def</span> <span class="nf">dscp</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">,</span> <span class="n">timeout</span><span class="o">=</span><span class="mi">9000</span><span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    copy [hostname]:[src] to [localhost]:[dst].</span>

<span class="sd">    :return:</span>
<span class="sd">           a dict with keys (&#39;exitstatus&#39;, &#39;result&#39;) exitstatus 0 success -1 others</span>
<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;result&#39;</span><span class="p">:</span> <span class="s1">&#39;&#39;</span>
    <span class="p">}</span>
    <span class="n">client</span><span class="p">,</span> <span class="n">sftp</span> <span class="o">=</span> <span class="n">_sftp_connect</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">timeout</span><span class="p">,</span> <span class="mi">22</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">client</span> <span class="ow">or</span> <span class="ow">not</span> <span class="n">sftp</span><span class="p">:</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s1">&#39;connect remote host error&#39;</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">_is_exists</span><span class="p">(</span><span class="n">src</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="n">sftp</span><span class="o">.</span><span class="n">stat</span><span class="p">):</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&#39;&quot;</span> <span class="o">+</span> <span class="n">src</span> <span class="o">+</span> <span class="s2">&quot;&#39;: No such file or directory at remote&quot;</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">_is_exists</span><span class="p">(</span><span class="n">dst</span><span class="p">,</span> <span class="n">function</span><span class="o">=</span><span class="n">os</span><span class="o">.</span><span class="n">stat</span><span class="p">):</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="s2">&quot;&#39;&quot;</span> <span class="o">+</span> <span class="n">dst</span> <span class="o">+</span> <span class="s2">&quot;&#39;: No such file or directory in local&quot;</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="k">try</span><span class="p">:</span>
        <span class="n">msg</span> <span class="o">=</span> <span class="n">_get</span><span class="p">(</span><span class="n">sftp</span><span class="p">,</span> <span class="n">src</span><span class="p">,</span> <span class="n">dst</span><span class="p">)</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">msg</span>
        <span class="k">if</span> <span class="n">msg</span><span class="o">.</span><span class="fm">__contains__</span><span class="p">(</span><span class="s1">&#39;failed&#39;</span><span class="p">):</span>
            <span class="k">return</span> <span class="n">ret</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="mi">0</span>
    <span class="k">except</span> <span class="ne">Exception</span> <span class="k">as</span> <span class="n">e</span><span class="p">:</span>
        <span class="nb">print</span><span class="p">(</span><span class="s2">&quot;*** Caught exception: </span><span class="si">%s</span><span class="s2">: </span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">e</span><span class="o">.</span><span class="vm">__class__</span><span class="p">,</span> <span class="n">e</span><span class="p">))</span>
        <span class="n">traceback</span><span class="o">.</span><span class="n">print_exc</span><span class="p">()</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
        <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
    <span class="k">finally</span><span class="p">:</span>
        <span class="n">_close</span><span class="p">(</span><span class="n">client</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">ret</span></div>


<span class="k">def</span> <span class="nf">_judge_ret</span><span class="p">(</span><span class="n">ret</span><span class="p">,</span> <span class="n">msg</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">):</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="p">(</span><span class="n">ret</span><span class="p">[</span><span class="s1">&#39;exitstatus&#39;</span><span class="p">]):</span>
        <span class="k">return</span> <span class="kc">True</span>
    <span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">msg</span> <span class="o">+</span> <span class="s1">&#39; </span><span class="se">\n</span><span class="s1"> &#39;</span> <span class="o">+</span> <span class="nb">str</span><span class="p">(</span><span class="n">ret</span><span class="p">[</span><span class="s1">&#39;result&#39;</span><span class="p">])</span>
    <span class="k">return</span> <span class="kc">False</span>


<div class="viewcode-block" id="go_with_scp"><a class="viewcode-back" href="../../../cup.shell.html#cup.shell.expect.go_with_scp">[docs]</a><span class="k">def</span> <span class="nf">go_with_scp</span><span class="p">(</span>
    <span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">command</span><span class="o">=</span><span class="s1">&#39;&#39;</span><span class="p">,</span>
    <span class="n">host_tmp</span><span class="o">=</span><span class="s1">&#39;/tmp/&#39;</span><span class="p">,</span> <span class="n">remote_tmp</span><span class="o">=</span><span class="s1">&#39;/tmp/&#39;</span><span class="p">,</span>
    <span class="n">timeout</span><span class="o">=</span><span class="mi">800</span>
<span class="p">):</span>
<span class="w">    </span><span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Recommand using this function to remotely execute cmds.</span>

<span class="sd">    go_witch_scp will write a temp script file and scp to hostname:[host_tmp].</span>
<span class="sd">    Then execute it and get the result back.</span>

<span class="sd">    :param host_tmp:</span>
<span class="sd">        temp folder for keeping the temporary script file (contains the cmd)</span>
<span class="sd">    :param remote_tmp:</span>
<span class="sd">        remote temp folder for keeping the temporary script file</span>
<span class="sd">    :param timeout:</span>
<span class="sd">        timeout</span>

<span class="sd">    :return:</span>
<span class="sd">        a dict with keys (&#39;exitstatus&#39;, &#39;result&#39;)</span>

<span class="sd">    &quot;&quot;&quot;</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="p">{</span>
        <span class="s1">&#39;exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;remote_exitstatus&#39;</span><span class="p">:</span> <span class="o">-</span><span class="mi">1</span><span class="p">,</span>
        <span class="s1">&#39;result&#39;</span><span class="p">:</span> <span class="s1">&#39;write host file fail&#39;</span>
    <span class="p">}</span>
    <span class="n">tmp_filename</span> <span class="o">=</span> <span class="n">cup</span><span class="o">.</span><span class="n">util</span><span class="o">.</span><span class="n">CGeneratorMan</span><span class="p">()</span><span class="o">.</span><span class="n">get_uniqname</span><span class="p">()</span>
    <span class="n">host_file</span> <span class="o">=</span> <span class="n">host_tmp</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">tmp_filename</span>
    <span class="n">remote_file</span> <span class="o">=</span> <span class="n">remote_tmp</span> <span class="o">+</span> <span class="s1">&#39;/&#39;</span> <span class="o">+</span> <span class="n">tmp_filename</span>
    <span class="k">with</span> <span class="nb">open</span><span class="p">(</span><span class="n">host_file</span><span class="p">,</span> <span class="s1">&#39;w&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">fhandle</span><span class="p">:</span>
        <span class="n">fhandle</span><span class="o">.</span><span class="n">write</span><span class="p">(</span><span class="n">command</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">exists</span><span class="p">(</span><span class="n">host_file</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="n">lscp</span><span class="p">(</span><span class="n">host_file</span><span class="p">,</span> <span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">remote_tmp</span><span class="p">,</span> <span class="n">timeout</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">_judge_ret</span><span class="p">(</span><span class="n">ret</span><span class="p">,</span> <span class="s1">&#39;scp ret:&#39;</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">ret</span>
    <span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39; sh </span><span class="si">%s</span><span class="s1"> &#39;</span> <span class="o">%</span> <span class="n">remote_file</span>
    <span class="n">ret</span> <span class="o">=</span> <span class="n">go_ex</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">cmd</span><span class="p">,</span> <span class="n">timeout</span><span class="p">)</span>
    <span class="n">os</span><span class="o">.</span><span class="n">unlink</span><span class="p">(</span><span class="n">host_file</span><span class="p">)</span>
    <span class="n">cmd</span> <span class="o">=</span> <span class="s1">&#39; rm -f </span><span class="si">%s</span><span class="s1"> &#39;</span> <span class="o">%</span> <span class="n">remote_file</span>
    <span class="n">res</span> <span class="o">=</span> <span class="n">go_ex</span><span class="p">(</span><span class="n">hostname</span><span class="p">,</span> <span class="n">username</span><span class="p">,</span> <span class="n">passwd</span><span class="p">,</span> <span class="n">cmd</span><span class="p">,</span> <span class="mi">10</span><span class="p">)</span>
    <span class="k">if</span> <span class="ow">not</span> <span class="n">_judge_ret</span><span class="p">(</span><span class="n">res</span><span class="p">,</span> <span class="s1">&#39;rm -f remote_file ret:&#39;</span><span class="p">):</span>
        <span class="k">return</span> <span class="n">res</span>
    <span class="k">return</span> <span class="n">ret</span></div>

</pre></div>

          </div>
          
        </div>
      </div>
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
<h1 class="logo"><a href="../../../index.html">cup</a></h1>








<h3>Navigation</h3>
<p class="caption" role="heading"><span class="caption-text">Contents:</span></p>
<ul>
<li class="toctree-l1"><a class="reference internal" href="../../../cup.html">cup package</a></li>
</ul>

<div class="relations">
<h3>Related Topics</h3>
<ul>
  <li><a href="../../../index.html">Documentation overview</a><ul>
  <li><a href="../../index.html">Module code</a><ul>
  </ul></li>
  </ul></li>
</ul>
</div>
<div id="searchbox" style="display: none" role="search">
  <h3 id="searchlabel">Quick search</h3>
    <div class="searchformwrapper">
    <form class="search" action="../../../search.html" method="get">
      <input type="text" name="q" aria-labelledby="searchlabel" autocomplete="off" autocorrect="off" autocapitalize="off" spellcheck="false"/>
      <input type="submit" value="Go" />
    </form>
    </div>
</div>
<script>document.getElementById('searchbox').style.display = "block"</script>








        </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="footer">
      &copy;2023, CUP-DEV Team.
      
      |
      Powered by <a href="http://sphinx-doc.org/">Sphinx 7.0.1</a>
      &amp; <a href="https://github.com/bitprophet/alabaster">Alabaster 0.7.13</a>
      
    </div>

    

    
  </body>
</html>